package kubernetes

import (
	"fmt"
	"strings"
)

const (
	labelSelector = "labelSelector"

	creatorAnnotationKey = "creator"

	groupIDKey     = "endedgecloud.zjlab.io/groupid"
	userIDKey      = "endedgecloud.zjlab.io/useruuid"
	userNameKey    = "endedgecloud.zjlab.io/username"
	clusterNameKey = "endedgecloud.zjlab.io/cluster"
	appKey         = "k8s-app"

	clusterTypeKey = "endedgecloud.zjlab.io/clustertype"
)

func parseLabelSelector(originLabelSelector string) map[string]string {
	strs := strings.Split(originLabelSelector, ",")
	res := make(map[string]string, len(strs))
	for _, str := range strs {
		tmp := strings.Split(str, "=")
		if len(tmp) == 2 {
			res[tmp[0]] = tmp[1]
		}
	}
	return res
}

func constructLabelSelector(m map[string]string) string {
	strs := make([]string, 0, len(m))
	for k, v := range m {
		strs = append(strs, fmt.Sprintf("%v=%v", k, v))
	}
	return strings.Join(strs, ",")
}